f = open('file.txt', 'r+') f.truncate(0)
//one way is to open the file for writing file = open("sample.txt","w") file.close() //another way file = open("example.txt","r+") file.truncate(0) file.close()
open('file.txt', 'w').close()